//
//  SeverViewController.m
//  WZCLApp
//
//  Created by chirui on 2018/7/2.
//  Copyright © 2018年 Shui. All rights reserved.
//

#import "SeverViewController.h"
#import "SeverSecondListViewController.h"
#import "IncludeTitleDetailsVC.h"
#import "StudyReportListVC.h" // 学习报告
#import "WorkFirstViewController.h"


@interface SeverViewController ()

@end

@implementation SeverViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    UIView * bgView =[[UIView alloc]initWithFrame:CGRectMake(20, 20, WIDTH -40, HEIGHT - SH_TabBarHeight - SH_TopHeight - 40)];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 6.f;
    bgView.layer.masksToBounds = YES;
    [self.view addSubview:bgView];
    
    CGFloat width = WIDTH -40;
    CGFloat imageWide = 70;
    CGFloat gapWide = (width - 210)/4;
    
    NSArray * imageArray = @[@"icon_service_curriculum",@"icon_service_class",@"icon_service_newspaper",@"icon_service_syllabus",@"icon_service_report",@"icon_service_handout",@"icon_sevice_distribution",@"icon_service_more"];
    NSArray * titleArray = @[@"调课",@"转班",@"跨报",@"课程表",@"学习报告",@"作业讲义",@"校区分布",@"更多服务"];
  
    for (int i = 0; i<8; i++) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        btn.frame = CGRectMake( gapWide+gapWide *(i%3)+imageWide*(i%3), 40+20 *(i/3)+(imageWide+20)*(i/3) , imageWide, imageWide);
        btn.tag = 100 + i;
        btn.layer.cornerRadius = 30.f;
        btn.layer.masksToBounds = YES;
        [btn  setBackgroundImage:[UIImage imageNamed:imageArray[i]] forState:UIControlStateNormal];
        btn.backgroundColor =[UIColor whiteColor];
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:btn];
        
        UILabel *  label = [[UILabel alloc]init];
        label.center = CGPointMake(btn.center.x, btn.center.y + imageWide / 2.f +15);
        label.bounds = CGRectMake(0, 0, 100, 15);
        label.font = [UIFont systemFontOfSize:13];
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = titleArray[i];
        [bgView addSubview:label];
    }
}

- (void)btnClick:(UIButton *)btn {
   
    if (btn.tag<=103) {
        SeverSecondListViewController * sever = [[SeverSecondListViewController alloc]init];
        sever.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:sever animated:YES];
       
    }else if (btn.tag==104){
        StudyReportListVC * study = [[StudyReportListVC alloc]init];
        study.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:study animated:YES];
    
    }else if(btn.tag ==105){
        WorkFirstViewController * work = [[WorkFirstViewController alloc]init];
        work.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:work animated:YES];
    }else {
        
        SHuiMBhudTextTimeStr(@"更多服务");
    }
}


@end
